/**
 * 
 */
package org.mspring.crm.client.frame;

import java.util.Collections;
import java.util.List;

import org.mspring.crm.client.model.ItemModel;

import com.google.gwt.user.client.ui.Widget;

/**
 * @author Gao Youbo
 * @since 2012-3-12
 * 
 */
public final class FrameFactory {
    public static Widget createFrame(List<ItemModel> models) {
        FrameType target = FrameType.Simple;
        if (models != null && models.size() == 2) {
            target = FrameType.Split;
        }

        AbstractFrameCreator creator = null;
        switch (target) {
        case Simple:
            creator = new SimpleFrameCreator();
            break;

        case Split:
            creator = new SplitFrameCreator();
            break;
        }
        ItemModel[] modelArray = new ItemModel[models.size()];
        modelArray = models.toArray(modelArray);
        return creator.createFrame(modelArray);
    }
}
